package com.bss.model;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.bss.AbstractEntity;

@Entity
@Table(name = "currentattendent")
public class CurrentAttendent extends AbstractEntity {

	private static final long serialVersionUID = 1193760685940559015L;

	private int id;

	private Admission admission;

	private Attendent attendent;

	private Date dateOfArrival = new Date();

	private Date dateOfLeave = new Date();

	@Id
	@Column(name = "id", unique = true, nullable = false)
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return this.id;
	}

	@Override
	public void setId(final int id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER,cascade = CascadeType.ALL)
	@JoinColumn(name = "idAdmission")
	public Admission getAdmission() {
		return this.admission;
	}

	public void setAdmission(final Admission admission) {
		this.admission = admission;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "dateOfArrival", length = 19)
	public Date getDateOfArrival() {
		return this.dateOfArrival;
	}

	public void setDateOfArrival(final Date dateOfArrival) {
		this.dateOfArrival = dateOfArrival;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "dateOfLeave", length = 19)
	public Date getDateOfLeave() {
		return this.dateOfLeave;
	}

	public void setDateOfLeave(final Date dateOfLeave) {
		this.dateOfLeave = dateOfLeave;
	}

	public void setAttendent(final Attendent attendent) {
		this.attendent = attendent;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "idAttendent")
	public Attendent getAttendent() {
		return this.attendent;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "date", length = 19)
	public Date getDate() {
		return this.date;
	}
}
